package com.mobimagic.lockscreen.view;

import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Style;

/**
 *
 * alpha和color分离
 * 
 * @Description
 */
public class AlphaPaint {

    private Paint paint = new Paint();

    private boolean hasColor = false;
    private int color = 0;
    private float animatAlpha;
    private int alpha;

    public void setStrokeCap(Cap cap) {
        paint.setStrokeCap(cap);
    }

    public int getAlpha() {
        return alpha;
    }

    public void setAlpha(int alpha) {
        this.alpha = alpha;
    }

    public float getAnimatAlpha() {
        return animatAlpha;
    }

    public void setAnimatAlpha(float animatAlpha) {
        this.animatAlpha = animatAlpha;
    }

    public int getColor() {
        return color;
    }

    public void setColor(int color) {
        this.color = color;
        hasColor = true;
    }

    public Paint getPaint() {
        return paint;
    }

    public void setPaint(Paint paint) {
        this.paint = paint;
    }

    public Paint widthColorAlpha() {
        if (hasColor) {
            paint.setColor(color);
            int alpha = Color.alpha(color);
            int resultAlpha = (int) (this.animatAlpha * alpha);
            paint.setAlpha(resultAlpha);
        } else {
            paint.setAlpha(alpha);
            int resultAlpha = (int) (this.animatAlpha * this.alpha);
            paint.setAlpha(resultAlpha);
        }
        return paint;
    }

    public void setStyle(Style stroke) {
        paint.setStyle(stroke);

    }

    public void setStrokeWidth(float paintWidth) {
        paint.setStrokeWidth(paintWidth);
    }

    public void setAntiAlias(boolean b) {
        paint.setAntiAlias(b);
    }
}
